<%@ taglib prefix="page" uri="http://com.qipay/pagelib" %>
<%@ page language="java" import="com.qipay.admin.tags.PageModel" contentType="text/html;charset=utf-8" %>
<%@ page import="com.qipay.baas.model.Message" %>
<%@ page import="java.util.Iterator" %>

<%@ page import="java.util.List" %>
<!doctype html>
<html>
<head>
    <jsp:include page="head.jsp"></jsp:include>
    <link rel="stylesheet" href="<%= request.getAttribute("StaticHost") %>/css/dataTables.bootstrap.min.css">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <jsp:include page="nav.jsp"></jsp:include>
    <jsp:include page="left.jsp"></jsp:include>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <h3 class="box-title">消息列表</h3>
                        </div>
                        <div class="col-xs-10">
                            <form class="form-inline">
                                <span class="help-inline">类型：</span>
                                <select id="ddltype" name="type">
                                    <option value="0">未读</option>
                                    <option value="1">全部</option>
                                </select>
                            </form>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <table id="example2" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>来源</th>
                                    <th>内容</th>
                                    <th>状态</th>

                                </tr>
                                </thead>
                                <tbody>
                                <% List<Message> articles = (List<Message>) request.getAttribute("lst");
                                    PageModel pager = (PageModel) request.getAttribute("page");
                                    String query = pageContext.getRequest().getServletContext().getContextPath() + "/sys/msg" + pager.getUrl();
                                    if (articles != null && articles.size() > 0) {
                                        Iterator<Message> iter = articles.iterator();
                                        Message user = null;
                                        while (iter.hasNext()) {
                                            user = iter.next();
                                %>
                                <tr id="user_<%=user.getId()%>">
                                    <td><%=user.getId()%>
                                    </td>
                                    <td><%=user.getSendName()%>

                                    </td>
                                    <td><%=user.getContent()%>
                                    </td>
                                    <td>
                                        <%= user.getStatus() != null && user.getStatus() == 0 ? "未读" : "已读"%>
                                    </td>

                                </tr>
                                <%
                                    }
                                } else {
                                %>
                                <tr>
                                    <td colspan="4">no data.</td>
                                </tr>
                                <% }%>
                                </tbody>
                            </table>
                            <div class="col-sm-10">

                                <div class="dataTables_paginate paging_simple_numbers" id="example1_paginate">
                                    <page:page totalSum="<%= pager.getTotal()%>"
                                               url="<%= query%>"
                                               pageNo="<%= pager.getPage()%>"
                                               pageSize="<%= pager.getPageSize()%>"></page:page>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <jsp:include page="foot.jsp"></jsp:include>
</div>
<script src="<%= request.getAttribute("StaticHost") %>/js/jquery.dataTables.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/dataTables.bootstrap.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/jquery.slimscroll.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/fastclick.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/adminlte.min.js"></script>
<script>
    $(function () {
        var channelState = parseInt("<%= request.getParameter("t")!=null&&request.getParameter("t").endsWith("1")?1:0%>", 10);
        $("#ddltype").val(channelState);
        $("#ddltype").change(function () {
            window.location.href = "${pageContext.request.contextPath}/sys/msg?t=" + $(this).val();
        })
        $('#example2').DataTable({
            'paging': false,
            'lengthChange': false,
            'searching': false,
            'ordering': true,
            'info': true,
            'autoWidth': false
        })
    })
</script>
</body>
</html>

